// softlab javascript

/**
 * 修改密码。
 */
function change_pass(id)
{
	window.open("/member/password/AId/"+id, "Change_Password",
		"height=160,width=360,scrollbars=no,"+
		"location=no,menubar=no,toolbar=no");
}

/**
 * 显示用户信息。
 */
function show_member(id)
{
	window.location.href="/member/info/AId/"+id;
}

/**
 * 增加公开消息。
 */
function add_news()
{
	window.location.href="/info/edit_notice/private/0/NId/0";
}

/**
 * 增加内部通知。
 */
function add_notice()
{
	window.location.href="/info/edit_notice/private/1/NId/0";
}

/**
 * 打开增加人的窗口。
 */
function show_add_person()
{
	window.open("/member/add_person/Status/0/", "Add_ACCOUNT_Dlg",
		"height=240,width=460,scrollbars=no,"+
		"location=no,menubar=no,toolbar=no");
}

// 改变新增成员身份时触发
function on_change_status(sel)
{
	var val=$(sel).val();
	if (val==1 || val==2 || val==0)
		$("#enroll_date").show();
	else
		$("#enroll_date").hide();
	
}

// 删除一个人
function del_account(aid)
{
	if (confirm("are you sure?"))
		$.get("/member/del/AId/"+aid, function (result) {
			if (result=='1')
				window.location.reload();
			else
				alert("Oops! Delete operation failed!");
		});
}

/**
 * 增加一篇论文。
 */
function add_paper()
{
	var div=$("#paper_div");
	var p=$("#paper_link");

	window.open("/paper/add", "add",
		"height=400,width=600,scrollbars=no,"+
		"location=no,menubar=no,toolbar=no");
}

// 弹出上传头像框
function upload_icon(aid)
{
	window.open("/member/icon/AId/"+aid, "Upload_Dlg",
		"height=140,width=540,scrollbars=no,"+
		"location=no,menubar=no,toolbar=no");
}

// 进入修改成员页
function edit_member(aid)
{
	window.location.href="/member/info/AId/"+aid;
}

// 增加一门课程
function add_course()
{
	window.open("/education/add", "Update_Course",
		"height=500,width=660,scrollbars=yes,"+
		"location=no,menubar=no,toolbar=no");
}

// 修改课程信息
function edit_course(cid)
{
	window.open("/education/add/CId/"+cid, "Update_Course",
		"height=500,width=660,scrollbars=yes,"+
		"location=no,menubar=no,toolbar=no");
}

// 删除一门课程
function del_course(cid)
{
	if (confirm("are you sure?"))
		$.get("/education/del/CId/"+cid, function (result) {
			if (result=='1')
				window.location.reload();
			else
				alert("Oops! Delete operation failed!");
		});
}

// 增加课件
function add_courseware(cid)
{
	window.open("/education/add_ware/CId/"+cid, "Update_Ware",
		"height=180,width=480,scrollbars=no,"+
		"location=no,menubar=no,toolbar=no");
}

// 增加作业
function add_homework(cid)
{
	window.open("/education/add_homework/CId/"+cid, "Update_Homework",
		"height=500,width=480,scrollbars=no,"+
		"location=no,menubar=no,toolbar=no");
}

// 删除课件
function del_courseware(wid)
{
	if (confirm("are you sure?"))
		$.get("/education/delware/WId/"+wid, function (result) {
			if (result=='1')
				window.location.reload();
			else
				alert("Oops! Delete operation failed!");
		});
}

// 删除作业
function del_homework(hid)
{
	if (confirm("are you sure?"))
		$.get("/education/delwork/HId/"+hid, function (result) {
			if (result=='1')
				window.location.reload();
			else
				alert("Oops! Delete operation failed!");
		});
}

function show_homework(hid)
{
	window.open("/education/show_homework/HId/"+hid, "Homework",
		"height=500,width=500,scrollbars=yes,"+
		"location=no,menubar=no,toolbar=no");
}

// 编辑新闻
function edit_news(nid)
{
	window.location.href="/info/edit_notice/private/0/NId/"+nid;
}

// 编辑通知
function edit_notice(nid)
{
	window.location.href="/info/edit_notice/private/1/NId/"+nid;
}

// 删除新闻
function del_news(nid)
{
	if (confirm("are you sure?"))
		$.get("/info/del/NId/"+nid, function (result) {
			if (result=='1')
				window.location.reload();
			else
				alert("Oops! Delete operation failed!");
		});
}

// 删除通知
function del_notice(nid)
{
	del_news(nid);
}

// 管理窗口
function admin(url)
{
	window.open(url, "Admin_win",
		"height=480,width=640,scrollbars=yes,"+
		"location=no,menubar=no,toolbar=no");
}

// 转到修改静态页面页
function edit_static(name)
{
	window.location.href = '/home/edit/name/'+name;
}

// 删除静态页面
function del_page(name, file)
{
	if (confirm("are you sure?"))
		$.get("/home/del/name/"+name+"?file="+file, function (result) {
			if (result=='1')
				window.location.reload();
			else
				alert("Oops! Delete operation failed!");
		});
}

// 删除教师静态页面
function del_teacher_page(file)
{
	if (confirm("are you sure?"))
		$.get("/member/del?file="+file, function (result) {
			if (result=='1')
				window.location.reload();
			else
				alert("Oops! Delete operation failed!");
		});
}
